﻿using Basic.WxApiRemoteModel.WxMini;
using Basic.WxApiRemoteModel.WxMini.Model;
using Basic.WxApiService.Interface;
using Basic.WxApiService.WxModel.Platform;
using WeDonekRpc.Client.Interface;

namespace Basic.WxService.RpcEvent
{
    internal class WxMiniLoginEvent : IRpcApiService
    {
        private readonly IWxPlatformService _PlatformApi;

        public WxMiniLoginEvent (IWxPlatformService platformApi)
        {
            this._PlatformApi = platformApi;
        }

        public MiniLoginResult WxMiniLogin (WxMiniLogin param)
        {
            MiniLoginRes res = this._PlatformApi.MiniLogin(param.AppId, param.WxAppId, param.JsCode);
            return new MiniLoginResult
            {
                SessionKey = res.session_key,
                OpenId = res.openid,
                UnionId = res.unionid
            };
        }
    }
}
